import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import {
  ROLE_DATA_MANAGE,
  ROLE_FINANCE,
  ROLE_FINANCE_DATA, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING,
  ROLE_MIDDLE_TRANSFER,
  ROLE_ONE_SHIPPING,
  ROLE_REMITTANCE_MANAGE, ROLE_SHIPPING_PLAN, ROLE_STOCK_MANAGE, ROLE_USER_MANAGE
} from "@/utils/admin";
import FullPage from '@/layout/components/FullPage.vue' // 导入新的布局组件

/* Router Modules */

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/register',
    component: () => import('@/views/login/register'),
    name: 'register',
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/adminLogin',
    component: () => import('@/views/login/adminLogin'),
    name: 'adminLogin',
    hidden: true,
  },
  {
    path: '/backLogin',
    component: () => import('@/views/login/backLogin'),
    name: 'backLogin',
    hidden: true,
  },
  {
    path: '/test',
    component: () => import('@/views/test/test1'),
    name: 'test',
    hidden: true,
  },
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: '/index',
        component: () => import('@/views/index/index'),
        name: 'index',
        meta: { title: 'home', icon: 'el-icon-c-scale-to-original'},
        hidden: true
      },
      {
        path: '/minoDropshipping',
        component: () => import('@/views/minoDropshipping/index'),
        name: 'minoDropshipping',
        meta: { title: 'MinoDropshipping', roles:['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_INBOUND_SORTING], noCache: true,},
        hidden: true,
      },
      {
        path: '/minoFirstDropshipping',
        component: () => import('@/views/minoFirstDropshipping/index'),
        name: 'minoFirstDropshipping',
        meta: { title: 'minoFirstDropshipping', roles:['admin', ROLE_FIRST_LEG], noCache: true,},
        hidden: true,
      },
      {
        path: '/boxSizeHD',
        component: () => import('@/views/hardware/boxSizeHD'),
        name: 'boxSizeHD',
        meta: { title: '量方称重扫码一体机', roles:['admin', ROLE_FIRST_LEG], },
        hidden: true,
      },


    ]
  },


  {
    path: '/order',
    component: Layout,
    redirect: '/order/orderList',
    meta: {title:'orderManagement',roles:['admin', ROLE_ONE_SHIPPING], icon: 'circle'},
    children: [
      {
        path: '/order/orderList',
        component: () => import('@/views/order/orderList'),
        name: 'orderList',
        meta: { title: 'orderList', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
      },
      {
        path: '/order/orderInfo',
        component: () => import('@/views/order/orderInfo'),
        name: 'orderInfo',
        meta: { title: 'orderDetail', roles: ['admin', ROLE_ONE_SHIPPING], icon: '', noCache: true},
        hidden: true,
      },
      {
        path: '/order/cancelOrderList',
        component: () => import('@/views/order/cancelOrderList'),
        name: 'cancelOrderList',
        meta: { title: 'canceledOrderList', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
      },
      {
        path: '/order/returnOrderList',
        component: () => import('@/views/order/returnOrderList'),
        name: 'returnOrderList',
        meta: { title: 'listOfReturnedOrders', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
      },
      {
        path: '/order/sheinImgList',
        component: () => import('@/views/order/sheinImgList'),
        name: 'sheinImgList',
        meta: { title: 'sheinImgList', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
      },
      {
        path: '/shipment/uploadSheinImageInfo',
        component: () => import('@/views/order/uploadSheinImageInfo'),
        name: 'uploadSheinImageInfo',
        meta: { title: 'sheinImgList', roles: ['admin', ROLE_ONE_SHIPPING], icon: '', noCache: true,},
        hidden: true,
      },
      {
        path: '/order/cutOffList',
        component: () => import('@/views/order/cutOffList'),
        name: 'cutOffList',
        meta: { title: 'cutOffList', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
        hidden: true,
      },
    ]
  },
  // 拣货单
  {
    path: '/picking',
    component: Layout,
    redirect: '/picking/pickList',
    meta: { title:'pickingManagement', roles:['admin', ROLE_ONE_SHIPPING], icon: 'circle' },
    children: [
      {
        path: '/picking/packList',
        component: () => import('@/views/picking/packList'),
        name: 'packList',
        meta: { title: 'pickingList', roles: ['admin', ROLE_ONE_SHIPPING], icon: 'circle'},
      },
      {
        path: '/picking/packInfo',
        component: () => import('@/views/picking/packInfo'),
        name: 'packInfo',
        meta: { title: 'pickingDetails', roles: ['admin', ROLE_ONE_SHIPPING], icon: '', noCache: true,},
        hidden: true,
      },
      {
        path: '/picking/exceptGoodsList',
        component: () => import('@/views/picking/exceptGoodsList'),
        name: 'exceptGoodsList',
        meta: { title: '异常商品列表', roles: ['admin', ROLE_ONE_SHIPPING], icon: ''},
        hidden: true,
      },
    ]
  },
  // 货件管理
  {
    path: '/shipment',
    component: Layout,
    redirect: '/shipment/shippingPlanList',
    meta: {title:'shipmentManagement',roles:['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: 'circle'},
    children: [
      {
        path: '/shipment/shippingPlanList',
        component: () => import('@/views/shippingPlan/shippingPlanList'),
        name: 'shippingPlanList',
        meta: { title: '发货计划', roles: ['admin', ROLE_SHIPPING_PLAN, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: ''},
      },
      {
        path: '/shipment/shippingPlanInfo',
        component: () => import('@/views/shippingPlan/shippingPlanInfo'),
        name: 'shippingPlanInfo',
        meta: { title: '计划详情', roles: ['admin', ROLE_SHIPPING_PLAN, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: '', noCache: true,},
        hidden: true,
      },
      // {
      //   path: '/shipment/shipmentList',
      //   component: () => import('@/views/shipment/shipmentList'),
      //   name: 'shipmentList',
      //   meta: { title: '货件列表', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: ''},
      //   hidden: true,
      // },
      {
        path: '/shipment/shipmentListFirstLeg',
        component: () => import('@/views/shipment/shipmentList'),
        name: 'shipmentListFirstLeg',
        meta: { title: '头程货件', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: ''},
      },
      {
        path: '/shipment/shipmentListMoveWarehouse',
        component: () => import('@/views/shipment/mwShipmentList'),
        name: 'shipmentListMoveWarehouse',
        meta: { title: '移仓货件', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_INBOUND_SORTING], icon: ''},
      },

      // {
      //   path: '/shipment/confirmShipmentList',
      //   component: () => import('@/views/shipment/confirmShipmentList'),
      //   name: 'confirmShipmentList',
      //   meta: { title: 'confirmedShipmentList',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: ''},
      // },
      // {
      //   path: '/shipment/waitSendShipmentList',
      //   component: () => import('@/views/shipment/waitSendShipmentList'),
      //   name: 'waitSendShipmentList',
      //   meta: { title: 'toBeDeliveredShipmentList',  roles: ['admin', ROLE_MIDDLE_TRANSFER], icon: ''},
      // },
      // {
      //   path: '/shipment/cancelShipmentList',
      //   component: () => import('@/views/shipment/cancelShipmentList'),
      //   name: 'cancelShipmentList',
      //   meta: { title: 'cancelShipmentList',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: ''},
      // },
      //editUserShipment
      // {
      //   path: '/shipment/editUserShipment',
      //   component: () => import('@/views/shipment/editUserShipment'),
      //   name: 'editUserShipment',
      //   meta: { title: 'updateShipmentWarehousingQuantity',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: ''},
      //   hidden: true,
      // },
      {
        path: '/shipment/shipmentInfo',
        component: () => import('@/views/shipment/shipmentInfo'),
        name: 'shipmentInfo',
        meta: { title: 'shipmentDetails', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: '', noCache: true},
        hidden: true,
      },
      {
        path: '/shipment/uploadShipmentInfo',
        component: () => import('@/views/shipment/uploadShipmentInfo'),
        name: 'uploadShipmentInfo',
        meta: { title: 'shipmentDetails', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: '', noCache: true},
        hidden: true,
      },

    ]
  },
  // 货柜管理
  {
    path: '/container',
    component: Layout,
    redirect: '',
    meta: {title:'货柜管理',roles:['admin', ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: 'circle'},
    children: [
      {
        path: '/container/addContainer',
        component: () => import('@/views/container/addContainer'),
        name: 'addContainer',
        meta: { title: '添加货柜', roles: ['admin', ROLE_FIRST_LEG], icon: '', noCache: true, },
      },
      {
        path: '/container/containerList',
        component: () => import('@/views/container/containerList'),
        name: 'containerList',
        meta: { title: '海运货柜', roles: ['admin', ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: ''},
      },
      {
        path: '/container/airContainerList',
        component: () => import('@/views/container/airContainerList'),
        name: 'airContainerList',
        meta: { title: '空运货柜', roles: ['admin', ROLE_FIRST_LEG, ROLE_INBOUND_SORTING], icon: ''},
      },
      {
        path: '/container/containerInfo',
        component: () => import('@/views/container/containerInfo'),
        name: 'containerInfo',
        meta: { title: '货柜详情', roles: ['admin', ROLE_FIRST_LEG , ROLE_INBOUND_SORTING], icon: '', noCache: true, },
        hidden: true,
      }
    ],
  },
  // 库存管理
  {
    path: '/stock',
    component: Layout,
    redirect: '/stock/stockList',
    meta: {title:'inventoryManagement',roles:['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_STOCK_MANAGE, ROLE_INBOUND_SORTING], icon: 'circle'},
    children: [
      {
        path: '/stock/stockList',
        component: () => import('@/views/stock/stockList'),
        name: 'stockList',
        meta: { title: 'inventoryList', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_STOCK_MANAGE, ROLE_INBOUND_SORTING], icon: ''},
      },
      {
        path: '/stock/editStock',
        component: () => import('@/views/stock/editStock'),
        name: 'editStock',
        meta: { title: 'modifyInventory', roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_STOCK_MANAGE, ROLE_INBOUND_SORTING], icon: '', noCache: true,},
        hidden: true,
      },

      {
        path: '/stock/inventoryLocationList',
        component: () => import('@/views/stock/inventoryLocationList'),
        name: 'inventoryLocationList',
        meta: { title: 'inventoryLocationList',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER, ROLE_STOCK_MANAGE, ROLE_INBOUND_SORTING], icon: ''},
      },
    ]
  },
  {
    path: '/workOrder',
    component: Layout,
    redirect: '',
    meta: {title:'工单管理',roles:['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: 'circle'},
    children: [
      {
        path: '/labelOrder/labelOrderList',
        component: () => import('@/views/labelOrder/labelOrderList'),
        name: 'labelOrderList',
        meta: { title: 'labelList', roles: ['admin', ROLE_MIDDLE_TRANSFER, ROLE_ONE_SHIPPING], icon: ''},
      },
      {
        path: '/labelOrder/labelOrderInfo',
        component: () => import('@/views/labelOrder/labelOrderInfo'),
        name: 'labelOrderInfo',
        meta: { title: 'labelInfo',  roles: ['admin', ROLE_MIDDLE_TRANSFER, ROLE_ONE_SHIPPING], icon: '', noCache: true, },
        hidden: true,
      },
      {
        path: '/middleWork/middleList',
        component: () => import('@/views/middleWork/middleList'),
        name: 'middleList',
        meta: { title: 'middleList',  roles: ['admin', ROLE_MIDDLE_TRANSFER], icon: ''},
      },
      {
        path: '/stock/middleInfo',
        component: () => import('@/views/middleWork/middleInfo'),
        name: 'middleInfo',
        meta: { title: 'middleInfo',  roles: ['admin', ROLE_MIDDLE_TRANSFER], icon: '', noCache: true,},
        hidden: true,
      },
      {
        path: '/transferWork/transferList',
        component: () => import('@/views/transferWork/transferList'),
        name: 'transferList',
        meta: { title: 'transferList',  roles: ['admin', ROLE_MIDDLE_TRANSFER], icon: ''},
      },
      {
        path: '/transferWork/transferInfo',
        component: () => import('@/views/transferWork/transferInfo'),
        name: 'transferInfo',
        meta: { title: 'transferInfo',  roles: ['admin', ROLE_MIDDLE_TRANSFER], icon: '', noCache: true,},
        hidden: true,
      },
      {
        path: '/combination/combinationList',
        component: () => import('@/views/combination/combinationList'),
        name: 'combinationList',
        // 组装工单
        meta: { title: 'combinationList',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: ''},
      },
      {
        path: '/combination/combinationInfo',
        component: () => import('@/views/combination/combinationInfo'),
        name: 'combinationInfo',
        // 组装工单详情
        meta: { title: 'combinationInfo',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: '', noCache: true,},
        hidden: true,
      },
    ],
  },
  // 汇款管理
  {
    path: '/remittance',
    component: Layout,
    redirect: '/remittance/waitForConfirmationRemittance',
    meta: {title:'RemittanceManagement',roles:['admin', ROLE_FINANCE_DATA, ROLE_REMITTANCE_MANAGE], icon: 'circle'},
    children: [
      {
        path: '/remittance/waitForConfirmationRemittance',
        component: () => import('@/views/remittance/waitForConfirmationRemittance'),
        name: 'waitForConfirmationRemittance',
        meta: { title: 'RemittanceToBeConfirmed',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_REMITTANCE_MANAGE], icon: ''},
      },
      {
        path: '/remittance/confirmationRemittance',
        component: () => import('@/views/remittance/confirmationRemittance'),
        name: 'confirmationRemittance',
        meta: { title: 'ConfirmedRemittance',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_REMITTANCE_MANAGE], icon: ''},
      },
      {
        path: '/remittance/collectionAccountManagement',
        component: () => import('@/views/remittance/collectionAccountManagement'),
        name: 'collectionAccountManagement',
        meta: { title: 'CollectionAccountManagement',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_REMITTANCE_MANAGE], icon: ''},
      },
    ],
  },
  // 头程数据
  {
    path: '/FLData',
    component: Layout,
    redirect: '/FLData/shipmentData',
    meta: {title:'FLData',roles:['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: 'circle'},
    children: [
      // 货件数据
      {
        path: '/FLData/shipmentData',
        component: () => import('@/views/FLData/shipmentData'),
        name: 'shipmentData',
        meta: { title: 'shipmentData',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      // 货柜数据
      {
        path: '/FLData/containerData',
        component: () => import('@/views/FLData/containerData'),
        name: 'containerData',
        meta: { title: 'containerData',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      // 数据结算
      {
        path: '/FLData/FLDataSettlement',
        name: 'FLDataSettlement',
        component: () => import('@/views/FLData/FLDataSettlement'),
        meta: { title: 'dataSettlement',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      // 结算单
      {
        path: '/FLData/FLPayment',
        name: 'FLPayment',
        component: () => import('@/views/FLData/FLPayment'),
        meta: { title: 'settlementDoc',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      // 代理设置
      {
        path: '/FLData/agentSetting',
        component: () => import('@/views/FLData/agentSetting'),
        name: 'agentSetting',
        meta: { title: 'agentSetting',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      // 成本设置
      {
        path: '/FLData/costSetting',
        component: () => import('@/views/FLData/costSetting'),
        name: 'costSetting',
        meta: { title: 'costSetting',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/FLData/financeShipmentInfo',
        component: () => import('@/views/FLData/financeShipmentInfo'),
        name: 'financeShipmentInfo',
        meta: { title: 'financeShipmentInfo',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: '', noCache: true},
        hidden: true,
      },
      {
        path: '/FLData/financeContainerInfo',
        component: () => import('@/views/FLData/financeContainerInfo'),
        name: 'financeContainerInfo',
        meta: { title: 'financeContainerInfo',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: '', noCache: true},
        hidden: true,
      },
    ],
  },
  // 平台数据 （中控数据）
  {
    path: '/middle',
    component: Layout,
    redirect: '/middle/shipmentData',
    meta: {title:'平台数据',roles:['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: 'circle'},
    children: [
      {
        path: '/middle/shipmentData',
        component: () => import('@/views/middle/middleDataSettlement'),
        name: 'middleDataSettlement',
        meta: { title: 'dataSettlement',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/middle/middleSettlementList',
        component: () => import('@/views/middle/middleSettlementList'),
        name: 'middleSettlementList',
        meta: { title: 'settlementDoc',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/middle/middleSettlementInfo',
        component: () => import('@/views/middle/middleSettlementInfo'),
        name: 'middleSettlementInfo',
        meta: { title: 'middleSettlementInfo',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
        hidden: true,
      },
    ],
  },
  // 数据统计 statistics
  {
    path: '/statistics',
    component: Layout,
    redirect: '/statistics/incomeReport',
    meta: {title:'尾程数据',roles:['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: 'circle'},
    children: [
      {
        path: '/statistics/incomeReport',
        component: () => import('@/views/statistics/incomeReport'),
        name: 'incomeReport',
        meta: { title: 'incomeStatement',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE ], icon: ''},
      },
      {
        path: '/statistics/storage',
        component: () => import('@/views/statistics/storage'),
        name: 'storage',
        meta: { title: 'warehouseData',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/statistics/settlement',
        component: () => import('@/views/statistics/settlement'),
        name: 'settlement',
        meta: { title: 'dataSettlement',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/statistics/settlementList',
        component: () => import('@/views/statistics/settlementList'),
        name: 'settlementList',
        meta: { title: 'settlementDoc',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: ''},
      },
      {
        path: '/statistics/settlementInfo',
        component: () => import('@/views/statistics/settlementInfo'),
        name: 'settlementInfo',
        meta: { title: 'settlementDetails',  roles: ['admin', ROLE_FINANCE_DATA, ROLE_DATA_MANAGE], icon: '', noCache: true,},
        hidden: true,
      },
    ]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/index',
    meta: {title:'setting',roles:['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: 'circle'},
    children: [
      {
        path: '/setting/index',
        component: () => import('@/views/setting/index'),
        name: '',
        meta: { title: 'setting',  roles: ['admin', ROLE_ONE_SHIPPING, ROLE_MIDDLE_TRANSFER], icon: 'circle'},
      },
    ]
  },
  // 用户管理 user
  {
    path: '/user',
    component: Layout,
    redirect: '/user/userList',
    meta: {title:'user',roles:['admin', ROLE_USER_MANAGE], icon: 'circle'},
    children: [
      {
        path: '/user/amountUserList',
        component: () => import('@/views/user/userList'),
        name: 'amountUserList',
        meta: { title: 'amountUserList',  roles: ['admin', ROLE_USER_MANAGE], icon: ''},
      },
      {
        path: '/user/normalUserList',
        component: () => import('@/views/user/userList'),
        name: 'normalUserList',
        meta: { title: 'normalUserList',  roles: ['admin', ROLE_USER_MANAGE], icon: ''},
      },
      {
        path: '/user/invalidUserList',
        component: () => import('@/views/user/userList'),
        name: 'invalidUserList',
        meta: { title: 'invalidUserList',  roles: ['admin', ROLE_USER_MANAGE], icon: ''},
      },
      {
        path: '/user/userInfo',
        component: () => import('@/views/user/userInfo'),
        name: 'userInfo',
        meta: { title: 'userDetails',  roles: ['admin', ROLE_USER_MANAGE], icon: '', noCache: true,},
        hidden: true,
      },
      {
        path: '/user/rechargeRecord',
        component: () => import('@/views/user/rechargeRecord'),
        name: 'rechargeRecord',
        meta: { title: 'rechargeRecord',  roles: ['admin', ROLE_USER_MANAGE], icon: ''},
      },
      {
        path: '/user/addUser',
        component: () => import('@/views/user/addUser'),
        name: 'addUser',
        meta: { title: 'addUser',  roles: ['admin', ROLE_USER_MANAGE], icon: '', noCache: true,},
        hidden: true,
      },
    ]
  },
  //帮助中心  这个必须放最好，因为值需要登录权限，放前面有些账号登录了之后会直接到这个组件下
  {
    path: '/help',
    component: FullPage, // 使用新的布局组件
    hidden: true,
    redirect: '/help/helpDocument',
    meta: {title:'help', },
    children: [
      {
        name: 'DocumentList',
        path: '/help/helpDocument',
        component: () => import('@/views/help-document/index.vue'),
        meta: { title: '帮助中心'  },
        hidden: true
      }
    ]
  },




  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/index', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
